-- This demo shows the impact of the KS and WS settings. In the presentation this is 
-- slides-only. 
-- © Erland Sommarskog 2025.
CREATE DATABASE Japanese_CI_AI COLLATE Japanese_CI_AI
go
USE Japanese_CI_AI  -- Why AI? See below.
go
; WITH Kanawidth AS (
   SELECT a, b     -- Naka-Meguro
   FROM  (VALUES (N'なかめぐろ', N'ナカメグロ'),       -- Hiragana, Katakana
                 (N'Ｐａｒｉｓ', N'Paris'),           -- Fullwidth, Halfwidth
                 (N'ナカメグロ', N'ﾅｶﾒｸﾛ')) AS V(a, b) -- Ditto, in Katakana.
)
-- The len are there to show that everything is really five characters long.
SELECT a, b, len(a) AS len_a, len(b) AS len_b, 
       IIF(a = b, 'Equal', 'Different') AS Insensitive,
       IIF(a COLLATE Japanese_CI_AI_KS = 
           b COLLATE Japanese_CI_AI_KS, 'Equal', 'Different') AS KS,
       IIF(a COLLATE Japanese_CI_AI_WS = 
           b COLLATE Japanese_CI_AI_WS, 'Equal', 'Different') AS WS,
       IIF(a COLLATE Japanese_CI_AI_KS_WS = 
           b COLLATE Japanese_CI_AI_KS_WS, 'Equal', 'Different') AS KS_WS
FROM   Kanawidth

-- The reason that this demo uses an accent-insensitive database is that
-- there is no separate halfwidth version for the gu syllable, but the 
-- half-width version reads Naka-Mekuro. The gu syllable is written in 
-- both Hiragana and Katakana with the character for the syllable ku 
-- with an "accent" added to indicate voicing. 